#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <map> 
#include <unordered_set>

#define flr(x, l, r) for (int x = l; x <= r; ++x)
#define frl(x, r, l) for (int x = r; x >= l; --x)
#define fmp(x, t) for (int x = h[t]; ~x; x = ne[x])
#define LL long long
#define mt memset
#define my memcpy
#define szf sizeof
#define INF 0x3f3f3f3f
#define in(x) scanf("%d", &x)
#define out(x) printf("%d", x)
#define inll(x) scanf("%lld", &x)
#define outll(x) printf("%lld", x)
#define pn printf("\n")
#define con continue
#define bk break
#define vc vector
#define pb push_back
#define sz size
#define PII pair<int, int>
#define x first
#define y second
#define P_q priority_queue
#define ft front
#define pf push_front
#define popf pop_front
#define it insert
#define ct count

using namespace std;

typedef unsigned long long ULL;

const int N = 1010, M = 1010;

int n, m;
int h[N], e[M], ne[M], idx;
int dfn[N], low[N], timestamp;
int stk[N], top;
int dcc_cnt;
vc<int> dcc[N];
bool cut[N];
int root;

void add(int a, int b) {
    e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void tarjan(int u) {
    dfn[u] = low[u] = ++ timestamp;
    stk[ ++ top] = u;
    
    if (u == root && h[u] == -1) {
        dcc_cnt ++ ;
        dcc[dcc_cnt].pb(u);
        return ;
    }
    
    int cnt = 0;
    fmp (i, u) {
        int j = e[i];
        if (!dfn[j]) {
            tarjan(j);
            low[u] = min(low[u], low[j]);
            if (dfn[u] <= low[j]) {
                cnt ++ ;
                if (u != root || cnt > 1) cut[u] = true;
                ++ dcc_cnt;
                int y;
                do {
                    y = stk[top -- ];
                    dcc[dcc_cnt] .pb(y);
                } while (y != j);
                dcc[dcc_cnt].pb(u);
            }
        }
        else low[u] = min(low[u], dfn[j]);
    }
}

int main() {
	int T = 1;
	while (cin >> m, m) {
	    flr (i, 1, dcc_cnt) dcc[i].clear();
	    idx = n = timestamp = top = dcc_cnt = 0;
	    mt(h, -1, szf h);
	    mt(dfn, 0, szf dfn);
	    mt(cut, 0, szf cut);
	    
	    while (m -- ) {
	        int a, b;
	        cin >> a >> b;
	        n = max(n, a), n = max(n, b);
	        add(a, b), add(b, a);
	    }
	    
	    for (root = 1; root <= n; ++ root)
	        if (!dfn[root])
	            tarjan(root);
	            
	   int res = 0;
	   ULL num = 1;
	   flr (i, 1, dcc_cnt) {
	       int cnt = 0;
	       flr (j, 0, dcc[i].sz() - 1)
	            if (cut[dcc[i][j]])
	                cnt ++ ;
	       
	       if (cnt == 0) {
	           if (dcc[i].size() > 1) res += 2, num *= dcc[i].sz() * (dcc[i].sz() - 1) / 2;
	           else res ++ ;
	       }
	       else if (cnt == 1) res ++ , num *= dcc[i].sz() -  1;
	   }
	   
	   printf("Case %d: %d %llu\n", T ++ , res, num);
	}
	
    return 0;
}